package com.sharer.last.controller;


import com.sharer.last.base.constant.CommonConstant;
import com.sharer.last.base.model.R;
import com.sharer.last.model.vo.blog.ArchiveVO;
import com.sharer.last.service.ArchiveService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sharer.last.annotation.VisitLogger;
import com.sharer.last.enums.VisitBehavior;

import javax.annotation.Resource;

/**
 * 归档页面
 *
 * @ClassName ArchiveController
 * @Author wangjin
 * @Date 2023/5/5 21:05
 * @Description
 * @Version 1.0
 */
@RestController
@RequestMapping(CommonConstant.BLOG_FRONT_API + "/archive")
public class ArchiveController {

    @Resource
    ArchiveService archiveService;

    /**
     * 按年月分组归档公开博客 统计公开博客总数
     *
     * @return
     */
    @VisitLogger(VisitBehavior.ARCHIVE)
    @GetMapping("/getArchives")
    public R archives(@RequestHeader(value = "adminToken", defaultValue = "") String adminToken) {
        ArchiveVO archiveVO = archiveService.getArchiveBlogGroupByYearMonth(adminToken);
        return R.ok(archiveVO);
    }
}
